import type { MaybeRefOrGetter } from 'vue';
import { createInjectionState } from '@peng_kai/kit/libs/vueuse';

interface TAppContext {
  cdn: MaybeRefOrGetter<string | undefined | null>;
  www: MaybeRefOrGetter<string | undefined | null>;
}

export const [useProvideAppContext, useAppContext] = createInjectionState((context: TAppContext) => {
  const cdn = toRef(context.cdn);
  const www = toRef(context.www);

  return { cdn, www };
}, { injectionKey: 'APP_CONTEXT' });
